package cn.sdfykjyxgs.synclient.server;

import cn.sdfykjyxgs.synclient.base.API;
import cn.sdfykjyxgs.synclient.base.HttpResult;
import cn.sdfykjyxgs.synclient.config.HttpTool;
import cn.sdfykjyxgs.synclient.entity.FileSynConfig;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class FileServer {
    @Resource
    HttpTool httpTool;


    /**
     * 判断服务是否在线
     *
     * @return
     */
    public HttpResult serverIsOnline(FileSynConfig fileSynConfig) {
        HttpResult httpResult = httpTool.get(fileSynConfig.getIp(), fileSynConfig.getPort(), API.IS_ONLINE);
        return httpResult;
    }

    public HttpResult synFile(Long fileId) {
        HttpResult o = httpTool.synFile(API.LIMIT_SPEED, fileId);
        return o;
    }
}
